package sistemasdistribuidos;

import classesBase.ModelaTabela;
import classesBase.Venda;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.ListSelectionModel;
import telasMensagem.Bloqueio;
import telasMensagem.SimNao;

public class Vendas extends javax.swing.JDialog {

    //temp manda e recebe valor da tela e resultado da conta
    static double temp = 0;
    /*recebe sempre o valor do subtotal, que é o preço da soma dos produtos
     sem desconto*/
    static double subtotal = 0;
    static double desconto = 0;
    static String quebraGalho = null;
    static ModelaTabela modela = new ModelaTabela();
    static BigDecimal bd;
    static boolean fecha = false;
    static boolean clien = false;
    static Venda v = new Venda();
    static boolean conc = false;
    Date hoje = new Date();
    SimpleDateFormat formatar = new SimpleDateFormat("yyyy-MM-dd");

    public Vendas(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        modela.setColumnIdentifiers(new String[]{"Código", "Descrição",
            "Quantidade", "Preço", "Total"});
        modela.setColumnEditable(true, 2);
        jTableCompras.setModel(modela);
        jTableCompras.setRowHeight(20);
        jTableCompras.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jTableCompras.getColumnModel().getColumn(1).setPreferredWidth(250);
        jTableCompras.getColumnModel().getColumn(4).setPreferredWidth(100);
        jTextFieldCliente.setEditable(false);
        v.setData(formatar.format(hoje));
        //pegar o ultimo id e setar somando uma unidade
        v.setIdVenda(00001);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (jTableCompras.getRowCount() > 0) {
                    SimNao sn = new SimNao(null, true, "<html>Tem certeza que deseja cancelar "
                            + "esta compra? <br> Todas as informações"
                            + " serão perdidas!<html>", 15);
                    sn.setLocationRelativeTo(null);
                    sn.setVisible(true);
                    if (fecha == true) {
                        dispose();
                    }
                } else {
                    dispose();
                }
            }
        });
    }

    public static void fechar(boolean f) {
        fecha = f;
    }

    public static void cli(boolean f) {
        clien = f;
    }

    public static void abrirComanda(Double total, String cliente) {
        clien = false;
        if (jTextFieldCliente.getText().equals("Cliente Não Identificado") 
                || jTextFieldCliente.getText().equals(cliente)) {
            jTextFieldCliente.setText(cliente);
            clien = true;
        } else {
            if (!jTextFieldCliente.getText().equals(cliente)) {
                SimNao sn = new SimNao(null, true, "<html>A comanda selecionada pertence"
                        + " à outro cliente, deseja substituir o cliente da venda?<html>", 15);
                sn.setLocationRelativeTo(null);
                sn.setVisible(true);
                if (clien == true) {
                    jTextFieldCliente.setText(cliente);
                }
            }
        }
        if (clien == true) {
            soma(total);
            /*
             Buscar agendamento e adicionar serviços 
             */
        }
    }

    public static void blo(String men) {
        Bloqueio blo = new Bloqueio(null, true, men);
        blo.setLocationRelativeTo(null);
        blo.setVisible(true);
    }

    //soma o novo valor e devolve o total
    public static void soma(double valor) {
        try {
            //pegar o valor do subtotal pq ele sempre vai ter o valor total,
            //enquanto o Total conta com o desconto
            temp = valor + Double.valueOf(jTextFieldSubtotal.getText());
            //arrendondar para duas casas decimais
            bd = new BigDecimal(temp).setScale(2, RoundingMode.HALF_EVEN);
            //jogar no subtotal o valor total da soma dos produtos
            jTextFieldSubtotal.setText(String.valueOf(bd));
            //caso haja desconto
            if (Double.valueOf(jTextFieldDesconto.getText()) > 0) {
                desconto(Double.valueOf(jTextFieldDesconto.getText()));
            } else {
                jTextFieldValorTotal.setText(String.valueOf(bd));
            }
        } catch (Exception ex) {
            System.err.println(ex);
        }
    }

    //calcula o desconto
    public static void desconto(double desc) {
        try {
            /*
             pegar valores do tanto de desconto e da soma total
             dos valores dos proditos
             */
            subtotal = Double.valueOf(jTextFieldSubtotal.getText());
            //calcular valor do desconto
            desc = subtotal * (desc / 100);
            //tirar o valor do desconto do valor total
            desconto = subtotal - desc;
            //arredondar para duas casas decimais
            bd = new BigDecimal(desconto).setScale(2, RoundingMode.HALF_EVEN);
            //jogar resultado no total da compra
            jTextFieldValorTotal.setText(String.valueOf(bd));

        } catch (Exception ex) {
            System.err.println(ex);
        }
    }

    public static void cliente(String cli, int cod) {
        jTextFieldCliente.setText(cli);
        v.setCliente(cod);
    }

    public static void addProduto(String cod, String desc, String preco) {
        modela.addRow(new String[]{cod, desc, "1", preco, preco});
        temp = Double.parseDouble(preco);
        soma(temp);
    }

    public static void concluir(String fPagamento, String total, boolean vaiNaFe) {
        v.setPagamento(fPagamento);
        v.setTotal(total);
        conc = vaiNaFe;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jTextFieldCodProduto = new javax.swing.JTextField();
        jButtonPesquisarProduto = new javax.swing.JButton();
        jButtonPesquisarCliente = new javax.swing.JButton();
        jLabelMsg = new javax.swing.JLabel();
        jTextFieldCliente = new javax.swing.JTextField();
        jLabelMsg1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabelMsg2 = new javax.swing.JLabel();
        jLabelMsg3 = new javax.swing.JLabel();
        jLabelMsg4 = new javax.swing.JLabel();
        jLabelMsg5 = new javax.swing.JLabel();
        jTextFieldValorUnidade = new javax.swing.JTextField();
        jTextFieldDesconto = new javax.swing.JTextField();
        jTextFieldSubtotal = new javax.swing.JTextField();
        jTextFieldValorTotal = new javax.swing.JTextField();
        jLabelMsg6 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jButtonNovoCliente = new javax.swing.JButton();
        jButtonNovoProduto = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableCompras = new javax.swing.JTable();
        jButtonDeletarItem = new javax.swing.JButton();
        jButtonConcluir = new javax.swing.JButton();
        jButtonAbrirComanda = new javax.swing.JButton();
        jLabelMsg7 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Vendas");
        setModal(true);

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));
        jPanel1.setToolTipText("");
        jPanel1.setMaximumSize(new java.awt.Dimension(967, 505));

        jPanel2.setBackground(new java.awt.Color(255, 102, 0));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)), "Lista de Compras", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel2.setToolTipText("");

        jTextFieldCodProduto.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodProdutoActionPerformed(evt);
            }
        });
        jTextFieldCodProduto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldCodProdutoKeyPressed(evt);
            }
        });

        jButtonPesquisarProduto.setBackground(new java.awt.Color(255, 255, 255));
        jButtonPesquisarProduto.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jButtonPesquisarProduto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonPesquisarProduto.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonPesquisarProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPesquisarProdutoActionPerformed(evt);
            }
        });

        jButtonPesquisarCliente.setBackground(new java.awt.Color(255, 255, 255));
        jButtonPesquisarCliente.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jButtonPesquisarCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonPesquisarCliente.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonPesquisarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPesquisarClienteActionPerformed(evt);
            }
        });

        jLabelMsg.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg.setText("Produto:");
        jLabelMsg.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsgMouseClicked(evt);
            }
        });

        jTextFieldCliente.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCliente.setText("Cliente Não Identificado");
        jTextFieldCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldClienteActionPerformed(evt);
            }
        });

        jLabelMsg1.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg1.setText("Cliente:");
        jLabelMsg1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg1MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelMsg1)
                        .addGap(18, 18, 18)
                        .addComponent(jTextFieldCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonPesquisarCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jLabelMsg)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldCodProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonPesquisarProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextFieldCliente, jTextFieldCodProduto});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldCodProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMsg))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap(14, Short.MAX_VALUE)
                        .addComponent(jButtonPesquisarProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonPesquisarCliente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelMsg1)))
                .addContainerGap())
        );

        jPanel3.setBackground(new java.awt.Color(255, 102, 0));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)), "Lista de Compras", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N

        jLabelMsg2.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg2.setText("Subtotal:");

        jLabelMsg3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg3.setText("Valor Unitário:");

        jLabelMsg4.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg4.setText("Valor Total:");

        jLabelMsg5.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg5.setText("Desconto:");

        jTextFieldValorUnidade.setEditable(false);
        jTextFieldValorUnidade.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldValorUnidade.setText("0.00");

        jTextFieldDesconto.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldDesconto.setText("0");
        jTextFieldDesconto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldDescontoFocusLost(evt);
            }
        });
        jTextFieldDesconto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldDescontoKeyPressed(evt);
            }
        });

        jTextFieldSubtotal.setEditable(false);
        jTextFieldSubtotal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldSubtotal.setText("0.00");
        jTextFieldSubtotal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldSubtotalActionPerformed(evt);
            }
        });

        jTextFieldValorTotal.setEditable(false);
        jTextFieldValorTotal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldValorTotal.setText("0.00");

        jLabelMsg6.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg6.setText("%");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMsg2)
                            .addComponent(jLabelMsg5))
                        .addGap(57, 57, 57))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMsg4)
                            .addComponent(jLabelMsg3))
                        .addGap(18, 18, 18)))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldValorUnidade, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jTextFieldValorTotal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jTextFieldDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabelMsg6)))))
                .addGap(20, 20, 20))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg3)
                    .addComponent(jTextFieldValorUnidade, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg5)
                    .addComponent(jTextFieldDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMsg6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg2)
                    .addComponent(jTextFieldSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg4)
                    .addComponent(jTextFieldValorTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBackground(new java.awt.Color(255, 102, 0));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)), "Lista de Compras", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel5.setToolTipText("");

        jButtonNovoCliente.setBackground(new java.awt.Color(255, 255, 255));
        jButtonNovoCliente.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jButtonNovoCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/osso.png"))); // NOI18N
        jButtonNovoCliente.setText("Novo Cliente");
        jButtonNovoCliente.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonNovoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNovoClienteActionPerformed(evt);
            }
        });

        jButtonNovoProduto.setBackground(new java.awt.Color(255, 255, 255));
        jButtonNovoProduto.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jButtonNovoProduto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/osso.png"))); // NOI18N
        jButtonNovoProduto.setText("Novo Produto");
        jButtonNovoProduto.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonNovoProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNovoProdutoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonNovoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonNovoProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonNovoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonNovoProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel6.setBackground(new java.awt.Color(255, 102, 0));
        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)), "Lista de Compras", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel6.setToolTipText("");

        jTableCompras.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(0, 0, 0), new java.awt.Color(255, 153, 255)));
        jTableCompras.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTableCompras.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição", "Quantidade", "Preço", "Total"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableCompras.setColumnSelectionAllowed(true);
        jTableCompras.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jTableCompras.setRowHeight(25);
        jTableCompras.getTableHeader().setReorderingAllowed(false);
        jTableCompras.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableComprasMouseClicked(evt);
            }
        });
        jTableCompras.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentRemoved(java.awt.event.ContainerEvent evt) {
                jTableComprasComponentRemoved(evt);
            }
        });
        jTableCompras.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTableComprasFocusLost(evt);
            }
        });
        jScrollPane1.setViewportView(jTableCompras);
        jTableCompras.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        if (jTableCompras.getColumnModel().getColumnCount() > 0) {
            jTableCompras.getColumnModel().getColumn(2).setResizable(false);
            jTableCompras.getColumnModel().getColumn(3).setResizable(false);
            jTableCompras.getColumnModel().getColumn(4).setResizable(false);
        }

        jButtonDeletarItem.setBackground(new java.awt.Color(255, 255, 255));
        jButtonDeletarItem.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        jButtonDeletarItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonDeletarItem.setText("Deletar Item");
        jButtonDeletarItem.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonDeletarItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeletarItemActionPerformed(evt);
            }
        });

        jButtonConcluir.setBackground(new java.awt.Color(255, 255, 255));
        jButtonConcluir.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        jButtonConcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonConcluir.setText("Concluir");
        jButtonConcluir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonConcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConcluirActionPerformed(evt);
            }
        });

        jButtonAbrirComanda.setBackground(new java.awt.Color(255, 255, 255));
        jButtonAbrirComanda.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        jButtonAbrirComanda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonAbrirComanda.setText("Abrir Comanda");
        jButtonAbrirComanda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonAbrirComanda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAbrirComandaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 548, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jButtonAbrirComanda, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonDeletarItem, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonConcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonAbrirComanda, jButtonConcluir});

        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonConcluir)
                    .addComponent(jButtonDeletarItem)
                    .addComponent(jButtonAbrirComanda))
                .addContainerGap())
        );

        jPanel6Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonAbrirComanda, jButtonConcluir, jButtonDeletarItem});

        jLabelMsg7.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/bicharada.png"))); // NOI18N
        jLabelMsg7.setToolTipText("Módulo Frente de Caixa");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelMsg7, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabelMsg7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(19, 19, 19))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextFieldCodProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodProdutoActionPerformed

    }//GEN-LAST:event_jTextFieldCodProdutoActionPerformed

    private void jTextFieldCodProdutoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCodProdutoKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            modela.addRow(new String[]{"1", "dgasd", "1", "3.00", "3.00"});
            temp = Double.parseDouble((String) jTableCompras.getValueAt(jTableCompras.getRowCount() - 1, 4));
            soma(temp);
        }
    }//GEN-LAST:event_jTextFieldCodProdutoKeyPressed

    private void jButtonPesquisarProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPesquisarProdutoActionPerformed
        ProdutosCadastrados p = new ProdutosCadastrados(null, true, 1);
        p.setLocationRelativeTo(null);
        p.setVisible(true);
        /*

         Buscar Produtos!!!!
         ********** Banco de Dados ***********

         */
    }//GEN-LAST:event_jButtonPesquisarProdutoActionPerformed

    private void jButtonPesquisarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPesquisarClienteActionPerformed
        ClientesCadastrados cli = new ClientesCadastrados(null, true, 3);
        cli.setLocationRelativeTo(null);
        cli.setVisible(true);
    }//GEN-LAST:event_jButtonPesquisarClienteActionPerformed

    private void jLabelMsgMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsgMouseClicked
        //Abrir ficha do cliente
    }//GEN-LAST:event_jLabelMsgMouseClicked

    private void jTextFieldClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldClienteActionPerformed

    }//GEN-LAST:event_jTextFieldClienteActionPerformed

    private void jLabelMsg1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg1MouseClicked
        // Abrir ficha do produto selecionado
    }//GEN-LAST:event_jLabelMsg1MouseClicked

    private void jTextFieldDescontoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldDescontoKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                desconto(Double.valueOf(jTextFieldDesconto.getText()));
            } catch (Exception ex) {
                blo("<html>Valor de desconto inválido! <br>"
                        + "Por favor, adicione o valor em porcentagem que"
                        + " deseja ser descontado!</html>");
            }
        }
    }//GEN-LAST:event_jTextFieldDescontoKeyPressed

    private void jTextFieldSubtotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldSubtotalActionPerformed

    }//GEN-LAST:event_jTextFieldSubtotalActionPerformed

    private void jButtonNovoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNovoClienteActionPerformed
        CadastroCliente cc = new CadastroCliente(null, true);
        cc.setLocationRelativeTo(null);
        cc.setVisible(true);
    }//GEN-LAST:event_jButtonNovoClienteActionPerformed

    private void jButtonNovoProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNovoProdutoActionPerformed
        CadastroProduto cp = new CadastroProduto(null, true);
        cp.setLocationRelativeTo(null);
        cp.setVisible(true);
    }//GEN-LAST:event_jButtonNovoProdutoActionPerformed

    private void jTableComprasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableComprasMouseClicked
        jTextFieldValorUnidade.setText((String) jTableCompras.getValueAt(jTableCompras.getSelectedRow(), 3));
    }//GEN-LAST:event_jTableComprasMouseClicked

    private void jButtonDeletarItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeletarItemActionPerformed
        try {
            jTextFieldValorUnidade.setText("0.00");
            //pegar o valor que será retirado e o total
            temp = Double.parseDouble(String.valueOf(jTableCompras.getValueAt(jTableCompras.getSelectedRow(), 4)));
            subtotal = Double.parseDouble(jTextFieldSubtotal.getText());
            //subtrair do total
            subtotal = subtotal - temp;
            bd = new BigDecimal(subtotal).setScale(2, RoundingMode.HALF_EVEN);
            //jogar o novo total na tela
            jTextFieldSubtotal.setText(String.valueOf(bd));
            desconto(Double.parseDouble(jTextFieldDesconto.getText()));
            modela.removeRow(jTableCompras.getSelectedRow());
        } catch (Exception ex) {
            blo("<html>Nenhum item da venda foi selecionado! <br>"
                    + " Por favor, selecione na tabela o item que deseja deletar!</html>");
        }
    }//GEN-LAST:event_jButtonDeletarItemActionPerformed

    private void jButtonConcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConcluirActionPerformed
        if (jTableCompras.getRowCount() < 1) {
            blo("<html> Nenhum produto foi adicionado à compra!"
                    + "<br> Você deve adicionar no mínimo um "
                    + "à venda antes de concluí-la!</html>");
        } else {
            //chamar tela para inserir o pagamento
            try {
                temp = Double.parseDouble(jTextFieldValorTotal.getText());
                FecharVenda fv = new FecharVenda(null, true, temp);
                fv.setLocationRelativeTo(null);
                fv.setVisible(true);
            } catch (Exception ex) {
                System.out.print(ex);
            }
            if (conc == true) {
                for (int i = 0; i < jTableCompras.getRowCount(); i++) {
                    System.out.println("Venda: 0001 \n Código: " + jTableCompras.getValueAt(i, 0));
                }
            }
        }
    }//GEN-LAST:event_jButtonConcluirActionPerformed

    private void jButtonAbrirComandaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAbrirComandaActionPerformed
        ComandasAbertas ca = new ComandasAbertas(null, true);
        ca.setLocationRelativeTo(null);
        ca.setVisible(true);
    }//GEN-LAST:event_jButtonAbrirComandaActionPerformed

    private void jTableComprasComponentRemoved(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_jTableComprasComponentRemoved
        try {
            //pegar o quanto já havia no total
            quebraGalho = String.valueOf(jTableCompras.getValueAt(jTableCompras.getSelectedRow(), 4));
            temp = Double.parseDouble(quebraGalho);
            //pegar o valor da quantidade
            double quan = Double.valueOf((String) jTableCompras.getValueAt(jTableCompras.getSelectedRow(), 2));
            //pegar o preço unitário
            double valor = Double.parseDouble((String) jTableCompras.getValueAt(jTableCompras.getSelectedRow(), 3));
            //fazer a conta para saber o total
            valor = (valor * quan);
            bd = new BigDecimal(valor).setScale(2, RoundingMode.HALF_EVEN);
            //setar o novo valor total na linha do produto
            modela.setValueAt(bd, jTableCompras.getSelectedRow(), 4);
            /*se o valor da nova soma for maior que o da antiga será necessário
             adiciona no total da compra*/
            if (valor > temp) {
                //soma o total da diferença entre os totais
                soma(valor - temp);
            } else {
                /*Se o valor novo for menor que o valor antigo será necessário
                 subtrair a quantia retirada*/
                if (valor < temp) {
                    //total que será necessário retirar do valor total da compra
                    valor = temp - valor;
                    //pegar o valor total da compra
                    temp = Double.parseDouble(jTextFieldSubtotal.getText());
                    //tirar o valor da diferença dos totais
                    temp = temp - valor;
                    //jogar o total de volta para a tela
                    bd = new BigDecimal(temp).setScale(2, RoundingMode.HALF_EVEN);
                    jTextFieldSubtotal.setText(String.valueOf(temp));
                }
            }
            desconto(Double.parseDouble(jTextFieldDesconto.getText()));
        } catch (Exception ex) {
            blo("<html>Quantidade inválida! <br>"
                    + " Por favor, adicione apenas números inteiros deste campo!</html>");
            System.out.println(ex);
        }
    }//GEN-LAST:event_jTableComprasComponentRemoved

    private void jTextFieldDescontoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldDescontoFocusLost
        try {
            desconto(Double.valueOf(jTextFieldDesconto.getText()));
        } catch (Exception ex) {
            jTextFieldDesconto.setText("0");
            desconto(Double.valueOf(jTextFieldDesconto.getText()));
        }
    }//GEN-LAST:event_jTextFieldDescontoFocusLost

    private void jTableComprasFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTableComprasFocusLost
        jTableCompras.setEnabled(false);
        jTableCompras.setEnabled(true);
    }//GEN-LAST:event_jTableComprasFocusLost

    public static void main(String args[]) {

        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Vendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Vendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Vendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Vendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Vendas dialog = new Vendas(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public static javax.swing.JButton jButtonAbrirComanda;
    public static javax.swing.JButton jButtonConcluir;
    public static javax.swing.JButton jButtonDeletarItem;
    private javax.swing.JButton jButtonNovoCliente;
    private javax.swing.JButton jButtonNovoProduto;
    public static javax.swing.JButton jButtonPesquisarCliente;
    public static javax.swing.JButton jButtonPesquisarProduto;
    public static javax.swing.JLabel jLabelMsg;
    public static javax.swing.JLabel jLabelMsg1;
    public static javax.swing.JLabel jLabelMsg2;
    public static javax.swing.JLabel jLabelMsg3;
    public static javax.swing.JLabel jLabelMsg4;
    public static javax.swing.JLabel jLabelMsg5;
    public static javax.swing.JLabel jLabelMsg6;
    public static javax.swing.JLabel jLabelMsg7;
    public static javax.swing.JPanel jPanel1;
    public static javax.swing.JPanel jPanel2;
    public static javax.swing.JPanel jPanel3;
    public static javax.swing.JPanel jPanel5;
    public static javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    public static javax.swing.JTable jTableCompras;
    public static javax.swing.JTextField jTextFieldCliente;
    public static javax.swing.JTextField jTextFieldCodProduto;
    public static javax.swing.JTextField jTextFieldDesconto;
    public static javax.swing.JTextField jTextFieldSubtotal;
    public static javax.swing.JTextField jTextFieldValorTotal;
    public static javax.swing.JTextField jTextFieldValorUnidade;
    // End of variables declaration//GEN-END:variables
}
